package org.code.boot.controller.boot;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.code.boot.common.annotation.Log;
import org.code.boot.common.enums.BusinessType;
import org.code.boot.controller.BaseController;
import org.code.boot.vo.AjaxResult;
import org.code.boot.domain.boot.BizTrainSeatConfig;
import org.code.boot.service.boot.IBizTrainSeatConfigService;
import org.code.boot.vo.TableDataInfo;

/**
 * 火车座位配置Controller
 * 
 * @author coder
 * @date 2025-08-28
 */
@RestController
@RequestMapping("/boot/trainseatconfig")
public class BizTrainSeatConfigController extends BaseController
{
    @Autowired
    private IBizTrainSeatConfigService bizTrainSeatConfigService;

    /**
     * 查询火车座位配置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BizTrainSeatConfig bizTrainSeatConfig)
    {
        startPage();
        List<BizTrainSeatConfig> list = bizTrainSeatConfigService.selectBizTrainSeatConfigList(bizTrainSeatConfig);
        return getDataTable(list);
    }

    /**
     * 根据火车ID查询座位配置列表
     */
    @GetMapping("/train/{trainId}")
    public AjaxResult getByTrainId(@PathVariable("trainId") Long trainId)
    {
        List<BizTrainSeatConfig> list = bizTrainSeatConfigService.selectBizTrainSeatConfigByTrainId(trainId);
        return success(list);
    }

    /**
     * 获取火车座位配置详细信息
     */
    @GetMapping(value = "/{seatConfigId}")
    public AjaxResult getInfo(@PathVariable("seatConfigId") Long seatConfigId)
    {
        return success(bizTrainSeatConfigService.selectBizTrainSeatConfigBySeatConfigId(seatConfigId));
    }

    /**
     * 新增火车座位配置
     */
    @Log(title = "火车座位配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTrainSeatConfig bizTrainSeatConfig)
    {
        bizTrainSeatConfig.setCreateBy(getNickname());
        return toAjax(bizTrainSeatConfigService.insertBizTrainSeatConfig(bizTrainSeatConfig));
    }

    /**
     * 修改火车座位配置
     */
    @Log(title = "火车座位配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTrainSeatConfig bizTrainSeatConfig)
    {
        bizTrainSeatConfig.setUpdateBy(getNickname());
        return toAjax(bizTrainSeatConfigService.updateBizTrainSeatConfig(bizTrainSeatConfig));
    }

    /**
     * 删除火车座位配置
     */
    @Log(title = "火车座位配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{seatConfigIds}")
    public AjaxResult remove(@PathVariable Long[] seatConfigIds)
    {
        return toAjax(bizTrainSeatConfigService.deleteBizTrainSeatConfigBySeatConfigIds(seatConfigIds));
    }
}